<template>
  <div style="width: 100%;position: relative;">
    <div style="background-color: #fff;padding: 0 20px;margin: 10px;border-radius: 5px;">
      <div style="display: flex;align-items: center;padding: 10px 0;">
        <div style="flex: 1;">
          <div style="text-align:center;width:60px;height:60px;text-align: right;overflow: hidden;">
            <img :src="avator" style="width: 100%; border-radius: 5px;"/>
          </div>
        </div>
        <div style="text-align: center;margin-right: 40px;padding-top: 4px;">
          <div style="font-size: 16px;color:#27173E;white-space:nowrap;overflow: hidden;">
            {{ userInfo.userProfile.username ? userInfo.userProfile.username : $t('defaultUserName') }}
          </div>
          <div>
            NO: {{ userInfo.userProfile.fansId }}
          </div>
        </div>
      </div>

      <hr color="#DCDCE9" size="0.1">

      <div style="padding: 15px 10px;">
        <div style="color: #999;text-align: center;">
          {{ $t('cashBalance') }}
        </div>
        <div style="display: flex;align-items: center;justify-content: space-between;">
          <div style="flex: 1;text-align: center;padding: 0 0 15px 0;direction: ltr;">
            <span style="font-size: 18px;">¥</span>
            <span style="font-size: 56px;font-weight: 800;">{{ userInfo.userProfile.cashBalance }}</span>
          </div>
        </div>
        <router-link :to="{ name: 'rechargePay' }">
          <div style="font-size: .9rem;width: 100px;background-color: #eea236;text-align: center;padding: 10px;color: #fff;margin: 0 auto;border-radius: 20px;">
            {{ $t('gotoRecharge') }}
          </div>
        </router-link>
      </div>
    </div>

    <div style="background-color: #fff;padding: 0 20px;margin: 10px;border-radius: 5px;">
      <flexbox :gutter="0" style="padding: 20px 0;">
        <flexbox-item style="text-align:center;">
          <wx-open-launch-weapp
            id="launch-btn"
            appid="wx5094228fa43e85a2"
            username="gh_c66f4a06d83c"
            path="pages/index/index">
            <script type="text/wxtag-template">
              <style>
                .wxapp-link {
                  text-align: center;
                  padding-top: 10px;
                }
                .wxapp-link img {
                  width: 36px;
                  height: 36px;
                  line-height: 36px;
                  vertical-align: -0.15em;
                }

                .wxapp-link p {
                  margin-top: 5px;
                }
              </style>
              <div class="wxapp-link">
                <img src="http://wx.qlogo.cn/mmhead/CttmTaYSYkQPiaUxEdXWIhg9EKImy9juWxGXNgcDTXrMiaKHSppkO3wCKWZaCptMW4ws1PibJJqxf8/0" >
                <p> Ghulja Uchur </p>
              </div>
            </script>
          </wx-open-launch-weapp>
        </flexbox-item>
      </flexbox>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { Flexbox, FlexboxItem, XButton } from 'vux'

const defaultAvator = 'unset.png'


export default {
  data() {
    return {
      title: 'Ghulja Uchur '
    }
  },
  computed: {
    ...mapGetters([
      'userInfo'
    ]),
    avator() {
      const avator = this.userInfo.userProfile.avator
                      ? this.userInfo.userProfile.avator
                      : defaultAvator

      return this.imageTrueUrl(avator , '-uchurheadimg')
    },
  },
  activated() {
    this.$store.dispatch('getUserProfile')
  },
  components: {
    Flexbox,
    FlexboxItem,
    XButton
  }
}
</script>

<style>

</style>